<!-- 自定义宏 -->

<!-- 页面头文件 -->
<!-- 参数说明 
	title： 标题 
    keywords： 关键字
    description：描述信息 
-->
<#macro head title keywords description>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="renderer" content="webkit">

    <title>${title}</title>

    <meta name="keywords" content="${keywords}">
    <meta name="description" content="${description}">

    <!--[if lt IE 8]>
    <script>
        alert('该系统不支持IE6-8，请使用谷歌、火狐等浏览器\n或360、QQ等国产浏览器的极速模式浏览本页面！');
    </script>
    <![endif]-->

    <link href="${basePath}/res/css/bootstrap.css" rel="stylesheet">
    <link href="${basePath}/res/css/font-awesome.min.css" rel="stylesheet">
    <link href="${basePath}/res/css/animate.css" rel="stylesheet">
    <link href="${basePath}/res/css/icons.css" rel="stylesheet">
    
    <!-- iCheck -->
    <link href="${basePath}/res/css/plugins/iCheck/custom.css" rel="stylesheet">
    <!-- bootstrap table -->
    <link href="${basePath}/res/css/plugins/bootstrap-table/bootstrap-table.css" rel="stylesheet">
 	<!-- jsTree -->
 	<link href="${basePath}/res/css/plugins/jsTree/style.min.css" rel="stylesheet">
 	<!-- chosen -->
 	<link href="${basePath}/res/css/plugins/chosen/chosen.css" rel="stylesheet">
 	<!-- checkbox -->
 	<link href="${basePath}/res/css/plugins/awesome-bootstrap-checkbox/awesome-bootstrap-checkbox.css" rel="stylesheet">
 	<!-- sweetalert -->
 	<link href="${basePath}/res/css/plugins/sweetalert/sweetalert.css" rel="stylesheet">
 	<!-- toastr -->
    <link href="${basePath}/res/css/plugins/toastr/toastr.min.css" rel="stylesheet">
    <!-- ztree -->
    <link href="${basePath}/res/css/plugins/ztree/metroStyle/metroStyle.css" rel="stylesheet">
    <!-- easyui -->
    <link href="${basePath}/res/css/plugins/easyui/bootstrap/easyui.css" rel="stylesheet">
 	<link href="${basePath}/res/css/plugins/easyui/icon.css" rel="stylesheet">
 	
 	<!-- Morris -->
    <link href="${basePath}/res/css/plugins/morris/morris-0.4.3.min.css" rel="stylesheet">
    <!-- Gritter -->
    <link href="${basePath}/res/js/plugins/gritter/jquery.gritter.css" rel="stylesheet">

 	
 	<link href="${basePath}/res/css/style.css?v=3.1.0" rel="stylesheet">
 
    <!-- ***************全局js*************** start -->
    <script src="${basePath}/res/js/jquery.min.js?v=2.1.4"></script>
    <script src="${basePath}/res/js/bootstrap.min.js?v=3.4.0"></script>
    <script src="${basePath}/res/js/plugins/metisMenu/jquery.metisMenu.js"></script>
    <script src="${basePath}/res/js/plugins/slimscroll/jquery.slimscroll.min.js"></script>
    <script src="${basePath}/res/js/plugins/layer/layer.min.js"></script>
    <!-- ***************全局js*************** end-->

	<!-- ***************第三方插件 start*************** -->
    <script src="${basePath}/res/js/plugins/pace/pace.min.js"></script>
    <!-- jquery表单验证插件 -->
    <script src="${basePath}/res/js/plugins/validate/jquery.validate.min.js"></script>
    <script src="${basePath}/res/js/plugins/validate/messages_zh.min.js"></script>
    <!-- iCheck -->
    <script src="${basePath}/res/js/plugins/iCheck/icheck.min.js"></script>
    <!-- Data Tables -->
    <script src="${basePath}/res/js/plugins/jeditable/jquery.jeditable.js"></script>
    <!-- bootstrap table -->
    <script src="${basePath}/res/js/plugins/bootstrap-table/bootstrap-table.js"></script>
    <script src="${basePath}/res/js/plugins/bootstrap-table/bootstrap-table-zh-CN.js"></script>
    <!-- 日期选择器插件 -->
    <script src="${basePath}/res/js/plugins/layer/laydate/laydate.js"></script>
    <!-- colResizable -->
    <script src="${basePath}/res/js/plugins/dataTables/colResizable-1.5.min.js"></script>
    <!-- ajax表单提交插件 -->
    <script src="${basePath}/res/js/plugins/jquery/jquery-form.js"></script>
    <!-- jsTree -->
    <script src="${basePath}/res/js/plugins/jsTree/jstree.min.js"></script>
    <!-- chosen -->
    <script src="${basePath}/res/js/plugins/chosen/chosen.jquery.js"></script>
    <!-- sweetalert -->
    <script src="${basePath}/res/js/plugins/sweetalert/sweetalert.min.js"></script>
    <!-- toastr -->
    <script src="${basePath}/res/js/plugins/toastr/toastr.min.js"></script>
    <!-- ztree -->
    <script src="${basePath}/res/js/plugins/ztree/jquery.ztree.all-3.5.min.js"></script>
	<!-- easyui -->
    <script src="${basePath}/res/js/plugins/easyui/jquery.easyui.min.js"></script>

    <!-- ***************自定义js*************** start -->
    <script src="${basePath}/res/js/main.js?v=3.1.0"></script>
    <script src="${basePath}/res/js/contabs.js"></script>
    <script src="${basePath}/res/js/content.js?v=1.0.0"></script>
    <!-- ***************自定义js*************** end -->

    
    
    <script type="text/javascript">
		//全局的AJAX访问，处理AJAX清求时SESSION超时
		$.ajaxSetup({
			contentType : "application/x-www-form-urlencoded;charset=utf-8",
			complete : function(XMLHttpRequest, textStatus) {
				// 通过XMLHttpRequest取得响应头，errorType
				var redirectUrl = XMLHttpRequest.getResponseHeader("redirectUrl");
				if (redirectUrl != null) {
					// 这里跳转到指定页面
					window.location.replace("${basePath}" + redirectUrl);
				}
			}
		}); 
	</script>
    
    
    <!-- ***************第三方插件*************** end -->
    <#nested>
</#macro>

<!-- 通用remote方式下的formModal -->
<!-- 参数说明 
	class： 模态框大小样式 
    id： 模态框id 
-->
<#macro remoteModal class="" id="formModal">
	<div class="modal inmodal fade" id="${id}" role="dialog"  aria-hidden="true" >
	    <div class="modal-dialog ${class}">
	        <div class="modal-content">
	            
	        </div>
	    </div>
	</div>
	<script>
		$(function(){
			$("#${id}").on("hidden.bs.modal", function() {
			    $(this).removeData("bs.modal");
			})
		})
	</script>
	<#nested>
</#macro>


<!-- 无限制操作 -->
<!-- 参数说明 
	buttonId： 按钮id, 默认为添加
    modalId： 模态框id 
	url： 请求地址     
-->
<#macro simple url buttonId="add" modalId="formModal">
	function ${buttonId}(){
		$("#${modalId}").modal({
    	    remote: "${url}"
    	})
	}
</#macro>

<!-- 单选操作 -->
<!-- 参数说明 
	buttonId： 按钮id, 默认为编辑
    tableId： 列表tableId 
    modalId： 模态框id
	url： 请求地址     
-->
<#macro single url buttonId="edit" modalId="formModal" tableId="table">
	function ${buttonId}(){
		var $selections = $("#${tableId}").bootstrapTable("getSelections");
		if($selections.length > 1) {
			toastr.warning("很抱歉,一次只能选择一条记录.","");
			return;
		}else if($selections.length == 0) {
			toastr.warning("您没有选择任何项,请您选中后操作.","");
			return;
		}
    	$("#${modalId}").modal({
    	    remote: "${url}/" + $selections[0].id
    	})
	
	}
</#macro>

<!-- 多选操作 -->
<!-- 参数说明 
	buttonId： 按钮id, 默认为编辑
    tableId： 列表tableId 
	url： 请求地址     
-->
<#macro multipart url buttonId="multipart" tableId="table">
	function ${buttonId}(){
		var $selections = $("#${tableId}").bootstrapTable("getSelections");
		if($selections.length == 0) {
			toastr.warning("您没有选择任何项,请您选中后操作.","");
			return;
		}
		var loading = layer.load();
   		var ids = [];
   		for(var index in $selections) {
   			ids.push($selections[index].id);
   		}
   		$.post("${url}", {
   			ids: ids.join(",")
   		}, function(resp){
   			layer.close(loading);
   			if(resp.code == 0) {
           		swal({
               		title: "操作成功",
               		type: "success",
               		showCancelButton: false,
               		confirmButtonColor: '#18a689',
               		confirmButtonText: '确定',
               		closeOnConfirm: true
                 },
               	function(){
               		$("#${tableId}").bootstrapTable('refresh');
               	});
       		}else if(resp.code == 1){
       			swal("操作失败！", resp.data, "error");
       		}else {
       			swal("操作失败！", "未知错误", "error");
       		}
   		},"json");
	}
</#macro>

<!-- 通用删除操作 -->
<!-- 参数说明 
	buttonId： 按钮id
    tableId： 列表tableId 
    modalId： 模态框id
	url： 请求地址     
-->
<#macro remove url buttonId="remove" tableId="table">
	function ${buttonId}(){
		var $selections = $("#${tableId}").bootstrapTable("getSelections");
		if($selections.length == 0) {
			toastr.warning("您没有选择任何项,请您选中后操作.","");
			return;
		}
	
		swal({
      		title: "您确定要删除这条信息吗?",
      		text: "删除后将无法恢复，请谨慎操作！",
      		type: "warning",
      		showCancelButton: true,
      		confirmButtonColor: '#DD6B55',
      		confirmButtonText: '确定',
      		cancelButtonText: "取消",
      		closeOnConfirm: false
      	},
      	function(){
      		var selections = $("#${tableId}").bootstrapTable("getSelections");
      		var ids = [];
      		for(var index in selections) {
      			ids.push(selections[index].id);
      		}
      		$.post("${url}", {
      			ids: ids.join(",")
      		}, function(resp){
      			if(resp.code == 0) {
	           		swal({
	               		title: "操作成功",
	               		type: "success",
	               		showCancelButton: false,
	               		confirmButtonColor: '#18a689',
	               		confirmButtonText: '确定',
	               		closeOnConfirm: true
	                 },
	               	function(){
	               		$("#${tableId}").bootstrapTable('refresh');
	               	});
	       		}else if(resp.code == 1){
	       			swal("操作失败！", resp.data, "error");
	       		}else {
	       			swal("操作失败！", "未知错误", "error");
	       		}
      		},"json");
      		
      	});
	
	}
</#macro>

<!-- 通用查询操作 -->
<!-- 参数说明 
	buttonId： 按钮id 
    tableId： 列表tableId 
    modalId： 模态框id
	url： 请求地址     
-->
<#macro search buttonId="search" modalId="searchModal" tableId="table">
	function ${buttonId}(){
		$("#${modalId}").modal()
	}
</#macro>


